/*
 * Copyright (c) 2017 Qunar.com. All Rights Reserved.
 */
package com.guoyu.project.common.ueditor;

import java.util.List;
import java.util.Map;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

/**
 * @author: libo Date: 17-6-20 Time: 上午10:32
 * @version: \$Id$
 */
public final class UeditorDefaultConfig {

    public final static String UPLOAD_ACTION_NAME = "upload";
    public final static String UPLOAD64_ACTION_NAME = "upload64";
    public final static String CATCHER_ACTION_NAME = "catcher";
    public final static String LISTFILE_ACTION_NAME = "listfile";
    public final static String LISTIMG_ACTION_NAME = "listimg";
    public final static String FILE_FIELD_NAME = "upfile";
    /** 文件大小限制 **/
    public final static Long MAX_SIZE = 2048000L;
    public final static String FILE_URL_PRE = "/uploader/ueditor/";
    public final static String PATH_FORMAT = "{ext}/{yyyy-mm-dd}/{time}{rand:6}";

    public final static String UPLOAD_URL_PRE = "";
    public final static String FILE_ALIGN = "none";

    public final static int LIST_FILE_SIZE = 20;

    public final static String[] IMA_SUFFIX_NAMES = new String[] { ".png", ".jpg", ".jpeg", ".gif", ".bmp" };

    public final static List<String> VIDEO_SUFFIX_NAMES = Lists.newArrayList(".flv", ".swf", ".mkv", ".avi", ".rm",
            ".rmvb", ".mpeg", ".mpg", ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid");

    public final static String[] ALL_FILE_SUFFIX_NAMES = new String[] { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".flv",
            ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm",
            ".mp3", ".wav", ".mid", ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso", ".doc", ".docx",
            ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml" };

    /******************* 抓取远程图片配置项 start ************************/

    /* 执行上传涂鸦的action名称 */
    public final static List<String> CATCHER_DOMAIN = Lists.newArrayList("127.0.0.1", "localhost", "img.baidu.com");

    /******************* 列出指定目录下的文件 end ************************/

    public final static Map<String, Object> defaultConfigMap = Maps.newHashMap();
    static {
        defaultConfigMap.put("imageActionName", UPLOAD_ACTION_NAME);
        defaultConfigMap.put("imageFieldName", FILE_FIELD_NAME);
        defaultConfigMap.put("imageMaxSize", MAX_SIZE);
        defaultConfigMap.put("imageAllowFiles", IMA_SUFFIX_NAMES);
        defaultConfigMap.put("imageCompressEnable", true);
        defaultConfigMap.put("imageCompressBorder", 1600);
        defaultConfigMap.put("imageInsertAlign", FILE_ALIGN);
        defaultConfigMap.put("imageUrlPrefix", UPLOAD_URL_PRE);
        defaultConfigMap.put("imagePathFormat", FILE_URL_PRE + PATH_FORMAT);

        defaultConfigMap.put("scrawlActionName", UPLOAD64_ACTION_NAME);
        defaultConfigMap.put("scrawlFieldName", FILE_FIELD_NAME);
        defaultConfigMap.put("scrawlPathFormat", FILE_URL_PRE + PATH_FORMAT);
        defaultConfigMap.put("scrawlMaxSize", MAX_SIZE);
        defaultConfigMap.put("scrawlUrlPrefix", UPLOAD_URL_PRE);
        defaultConfigMap.put("scrawlInsertAlign", FILE_ALIGN);

        defaultConfigMap.put("snapscreenActionName", UPLOAD_ACTION_NAME);
        defaultConfigMap.put("snapscreenPathFormat", FILE_URL_PRE + PATH_FORMAT);
        defaultConfigMap.put("snapscreenUrlPrefix", UPLOAD_URL_PRE);
        defaultConfigMap.put("snapscreenInsertAlign", FILE_ALIGN);

        defaultConfigMap.put("catcherLocalDomain", CATCHER_DOMAIN);
        defaultConfigMap.put("catcherActionName", CATCHER_ACTION_NAME);
        defaultConfigMap.put("catcherFieldName", FILE_FIELD_NAME);
        defaultConfigMap.put("catcherPathFormat", FILE_URL_PRE + PATH_FORMAT);
        defaultConfigMap.put("catcherUrlPrefix", UPLOAD_URL_PRE);
        defaultConfigMap.put("catcherMaxSize", MAX_SIZE);
        defaultConfigMap.put("catcherAllowFiles", IMA_SUFFIX_NAMES);

        defaultConfigMap.put("videoActionName", UPLOAD_ACTION_NAME);
        defaultConfigMap.put("videoFieldName", FILE_FIELD_NAME);
        defaultConfigMap.put("videoPathFormat", FILE_URL_PRE + PATH_FORMAT);
        defaultConfigMap.put("videoUrlPrefix", UPLOAD_URL_PRE);
        defaultConfigMap.put("videoMaxSize", MAX_SIZE * 10);
        defaultConfigMap.put("videoAllowFiles", VIDEO_SUFFIX_NAMES);

        defaultConfigMap.put("fileActionName", UPLOAD_ACTION_NAME);
        defaultConfigMap.put("fileFieldName", FILE_FIELD_NAME);
        defaultConfigMap.put("filePathFormat", FILE_URL_PRE + PATH_FORMAT);
        defaultConfigMap.put("fileUrlPrefix", UPLOAD_URL_PRE);
        defaultConfigMap.put("fileMaxSize", MAX_SIZE * 10);
        defaultConfigMap.put("fileAllowFiles", ALL_FILE_SUFFIX_NAMES);

        defaultConfigMap.put("imageManagerActionName", LISTIMG_ACTION_NAME);
        defaultConfigMap.put("imageManagerListPath", FILE_URL_PRE);
        defaultConfigMap.put("imageManagerListSize", LIST_FILE_SIZE);
        defaultConfigMap.put("imageManagerUrlPrefix", UPLOAD_URL_PRE);
        defaultConfigMap.put("imageManagerInsertAlign", FILE_ALIGN);
        defaultConfigMap.put("imageManagerAllowFiles", IMA_SUFFIX_NAMES);

        defaultConfigMap.put("fileManagerActionName", LISTFILE_ACTION_NAME);
        defaultConfigMap.put("fileManagerListPath", FILE_URL_PRE);
        defaultConfigMap.put("fileManagerListSize", LIST_FILE_SIZE);
        defaultConfigMap.put("fileManagerUrlPrefix", UPLOAD_URL_PRE);
        defaultConfigMap.put("fileManagerAllowFiles", ALL_FILE_SUFFIX_NAMES);
    }
}
